package com.dingwen.treasure.web.excption.handler.impl;

import com.dingwen.treasure.base.exception.BaseExceptionHandler;
import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.base.pojo.vo.ResultGenerator;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

import java.net.BindException;


/**
 * 　BindExceptionHandlerImpl： 参数绑定异常
 * 　@author dingwen
 * 　@date 2022/5/14$
 */
@Component("java.net.BindException")
public class BindExceptionHandlerImpl extends BaseExceptionHandler<Void> {


    /**
     * 根据异常构建统一返回结果
     *
     * @param exception 异常
     * @return result
     */
    @Override
    public Result<Void> buildResultByException(Exception exception) {
        BindException bindException = (BindException) exception;
        return ResultGenerator.genFailureResult(bindException.getMessage(), HttpStatus.BAD_REQUEST.value());
    }
}
